package ah.szxy;

import ah.szxy.domain.OrderTbl;
import ah.szxy.service.OrderService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单操作启动类(实现订单创建与账户的删减)
 *
 * @author caohaiyang
 * @create 2020-09-17 下午 04:48
 */
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("ah.szxy.mapper")
@RestController
@EnableFeignClients
public class OrderServiceApplication {
    @Autowired
    private OrderService orderService;

    public static void main(String[] args) {
        SpringApplication.run(OrderServiceApplication.class, args);
    }


    @GetMapping("/createOrder/{userId}/{productNo}/{count}")
    public ResponseEntity createOrder(
            @PathVariable("userId") String userId,
            @PathVariable("productNo") String productNo,
            @PathVariable("count") int count){
        OrderTbl order = orderService.createOrder(userId, productNo, count);
        return ResponseEntity.ok(order);
    }
}